package PTA.Mianxiangduixiang.ex26;

import Person.ith_34.Ma;

import javax.swing.plaf.ComponentInputMapUIResource;
import java.util.Scanner;
class Circle{
    private int radius;

    public Circle() {
radius=2;
        System.out.println("this is a constructor");
    }

    public Circle(int radius) {
        if(radius<=0){
            radius=2;
        }else{
            this.radius = radius;
        }
        System.out.println("this is a constructor with para");

    }

    public int getRadius() {
        return radius;
    }

    public void setRadius(int radius) {
        if (radius <= 0) {
            radius = 2;
        } else {
            this.radius = radius;
        }
    }
    public int getArea(){
        int area=0;
        double a=0;
        a = Math.PI*radius*radius;
        area=(int)a;
        return area;
    }

    @Override
    public String toString() {
        return "Circle [radius=" + radius + "]";
    }
}






public class ex26 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Circle c1 = new Circle();
        System.out.println(c1);
        System.out.println("c1:area="+c1.getArea());
        Circle c2 = new Circle();
        System.out.println(c2);
        int radius = sc.nextInt();
        c2.setRadius(radius);
        System.out.println(c2);
        System.out.println("c2:area="+c2.getArea());
        int a = sc.nextInt();
        Circle c3 = new Circle(a);
        System.out.println(c3);
        System.out.println("c3:area="+c3.getArea());



    }
}
